package com.itheima.mapper;

import com.itheima.pojo.CheckGroup;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealCheckGroupMapper {
    /**
     * 添加套餐和检查组关联关系
     * @param id
     * @param parseInt
     */
    @Insert("insert into t_setmeal_checkgroup (setmeal_id, checkgroup_id) VALUES (#{id},#{parseInt})")
    void insert(Integer id, int parseInt);

    /**
     * 根据套餐id删除套餐和检查组关联关系
     * @param id
     */
    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteBySetmealId(Integer id);

    /**
     * 根据套餐id查询关联的检查组id
     * @param id
     * @return
     */
    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id}")
    List<Integer> getCheckGroupIdsBySetmealId(Integer id);

    /**
     * 根据套餐id查询关联的检查组
     * @param id
     * @return
     */
    @Select("select * from t_checkgroup where id in (select checkgroup_id from t_setmeal_checkgroup where setmeal_id = #{id})")
    List<CheckGroup> getCheckGroupsBySetmealId(Integer id);
}
